﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EquationsBankReader.EquationsRead;

namespace EquationsBankSite.Controllers
{
    public class FunctionController : Controller
    {
        //
        // GET: /Function/

        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Index(HttpPostedFileBase equationsXmlFile)
        {
            var filePath = Server.MapPath("~/FunctionFiles/" + equationsXmlFile.FileName);
            equationsXmlFile.SaveAs(filePath);

            var reader = new EquationsReader(filePath);
            System.IO.File.Delete(filePath);
         
            return RedirectToAction("Index", "Home");
        }
         
    }
}
